<template>
  <div class="common-layout" style="height: 600px;">
    <el-container>
      <!--头-->
      <el-header style="height: 360px;background-color: white;">
        <el-container style="height: 550px;">
    
    <el-aside width="200px" style="margin-top: 50px;">
    <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess"
      :before-upload="beforeAvatarUpload">
  <img v-if="form.photoUrl" :src="'https://localhost:44391/img/'+form.photoUrl" class="avatar" style="max-width: 100%;max-height: 100%;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
   </el-aside>
   <el-main style="color: black;" #default="{row}">
    <table>
      <tr>
        <td>
          <h1 style="font-size: 30px;">{{ form.foodName }}</h1>
        </td>
        <td>
            <el-button type="info" size="small" style="margin-left: 300px;background-color: whitesmoke;color: black;" @click="open(row)">修改基本信息</el-button>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;"  @click="sym()">导出溯源码</el-button>
        </td>
      </tr>
    </table>
    <table style="margin: 10px;">
          <tr>
            <span>生产批次：{{ form.productionBatch}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>有效期：{{ form.shelfLife }}天</span> 
          </tr>
          <tr>
              <span>生产许可证号：{{ form.licenseNumber }}</span> &nbsp;&nbsp;
                 <span>生产企业：{{ form.enterprise }}</span>
             </tr>
              <tr>
                 <td>产品检验报告</td> &nbsp;&nbsp;
             </tr>
             <tr :inline="true">
              <td>
                <img v-for="item in imagesList" :src="item.url" style="width: 160px;height: 160px;margin-right: 15px;" @click="DeletedImage(item.url)"/>
             </td>
             <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess2"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
             </td>
             </tr>
         </table>
   </el-main>
 </el-container>
      </el-header>
      <!--头-->
      <!--身体-->
      <el-main style="height: 1250px;background-color: white;margin-top: 20px;color: black;">
        <div style="width: 1500px;height: 60px;">
          <el-radio-group v-model="isCard" size="large">
            <el-radio-button label="养殖信息(5/5)" value="1"/>
            <el-radio-button label="屠宰信息(5/5)" value="2"/>
            <el-radio-button label="深加工信息(5/5)" value="3"/>
          </el-radio-group>
        </div>
  <!-- 卡片一（养殖信息） -->
    <el-card style="max-width: 1500px;height: 1100px" v-show="isCard==1"  #default="{row}">
      <table>
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">养殖信息</span>&nbsp;&nbsp;
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;"  @click="openBreed(row)">设置</el-button>
        </td>
      </tr>
      </table>
      <table style="margin: 10px;">
          <tr>
            <span>品种：{{ breedForm.variety}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>来源：{{ breedForm.source }}</span> 
          </tr>
          <tr>
              <span>饲养天数：{{ breedForm.feedingDays }}天</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                 <span>饲养品种：{{ breedForm.feedingBrand }}</span>
             </tr>
              <tr>
                <span>饲养负责人：{{ breedForm.feedingName }}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <span>出栏日期：{{ moment(breedForm.saleDate).format("yyyy年MM月DD日") }}</span>
             </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">保健信息</span>&nbsp;&nbsp;
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="addImmunity" >新增行</el-button>
        </td>
      </tr>
    </table>
      </table>
    <hr style="border-width: 1px;color: black;">
    <!--疫苗信息-->
      <el-table :data="form.immunity" border style="width: 100%;margin-top: 20px;" >
    <el-table-column prop="feedingDays" label="饲养天数" width="180">
      <template #default="{row}">
        <el-input v-if="row.isAdd==true" v-model="row.feedingDays"/>
      </template>
    </el-table-column>
    <el-table-column prop="immunityType" label="保健方式" width="180" >
      <template #default="{row}">
        <el-input v-if="row.isAdd==true" v-model="row.immunityType"/>
      </template>
    </el-table-column>
    <el-table-column prop="immunityMethod" label="保健方法" width="180" >
      <template #default="{row}">
        <el-input v-if="row.isAdd==true" v-model="row.immunityMethod"/>
      </template>
    </el-table-column>
    <el-table-column prop="name" label="操作" width="180" #default="{row}">
        <el-button type="primary" v-if="row.isAdd==true" @click="saveImmunity(row)">保存</el-button>
      <el-button type="primary" v-if="row.isAdd==true" @click="cancelImmunity(row)">取消</el-button>
      <el-button type="primary" v-if="row.isAdd==false"  @click="updImmunity(row)">编辑</el-button>
      <el-button type="primary" v-if="row.isAdd==false" @click="delImmunity(row)" >删除</el-button>
    </el-table-column>
    
      </el-table>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">动检证</span>&nbsp;&nbsp;
        </td>
      </tr>
      </table>
    <hr style="border-width: 1px;color: black;">
    <!--动检证-->
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList3" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage3(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess3"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
          <span style="color: blue;font-size: 20px">企业信息</span>&nbsp;&nbsp;
          <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openFarm(row)" >设置</el-button>
        </td>
      </tr>
     </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin: 10px;">
          <tr>
            <span>养殖场：{{ farmForm.farm}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>负责人：{{ farmForm.custodian }}</span> 
          </tr>
          <tr>
              <span>存栏数量：{{ farmForm.feedNum }}只</span> 
             </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">企业照片</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--企业照片-->
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList4" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage4(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess4"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
  </el-card>
  <!--卡片二（屠宰信息）-->
  <el-card style="max-width: 1500px;height: 1000px" v-show="isCard==2" #default="{row}">
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">屠宰信息</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openSlaughte(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--屠宰设置-->
    <table style="margin: 10px;">
          <tr>
            <span>批次：{{ slaughteForm.productionBatch}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>到厂均重：{{ slaughteForm.averageWeight }}公斤</span> 
          </tr>
          <tr>
              <span>到厂时间：{{ slaughteForm.entryTime }}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>屠宰时间：{{ moment(slaughteForm.slaughteTime).format("yyyy年MM月DD日") }}</span> 
             </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">相关资料</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--相关资料-->
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList5" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage5(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess5"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">企业信息</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openSlaughteQ(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--设置屠宰企业-->
    <table style="margin: 10px;">
          <tr>
            <span>公司名称：{{ slaughteQForm.name}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>成立时间：{{ moment(slaughteQForm.foundTime).format("yyyy年MM月DD日") }}</span> 
          </tr>
          <tr>
              <span>公司地址：{{ slaughteQForm.address }}</span>  
          </tr>
          <tr>
              <span>公司简介：{{ slaughteQForm.summary }}</span>  
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">企业照片</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--企业照片-->
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList6" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage6(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess6"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
  </el-card>
  <!--卡片三（深加工信息）-->
  <el-card style="max-width: 1500px;height: 2600px" v-show="isCard==3" #default="{row}">
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">深加工信息</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openMachining(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--设置深加工-->
    <table style="margin: 10px;">
          <tr>
            <span>班组：{{ MachiningForm.team}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>负责人{{ MachiningForm.responsiblePerson }}</span> 
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">食品安全信息</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--食品安全照片-->
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList7" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage7(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess7"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: blue;font-size: 20px">供应商信息</span>
        </td>
      </tr>
    </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">原料</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openMachining2(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <!--设置原料-->
    <table style="margin: 10px;">
          <tr>
            <span>生产批次：{{ MachiningForm2.roductionBatch}}</span> 
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">相关资料</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList8" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage8(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess8"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">辅料</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openMachining3(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <!--设置辅料-->
    <table style="margin: 10px;">
          <tr>
            <span>生产批次：{{ MachiningForm3.productionBatch}}</span> 
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">相关材料</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList9" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage9(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess9"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">添加剂</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openMachining4(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <!--设置添加剂-->
    <table style="margin: 10px;">
          <tr>
            <span>生产批次：{{ MachiningForm4.productionBatch}}</span> 
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">相关材料</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList10" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage10(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess10"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">包材</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openMachining5(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <!--设置包材-->
    <table style="margin: 10px;">
          <tr>
            <span>生产批次：{{ MachiningForm5.productionBatch}}</span> 
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">相关材料</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList11" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage11(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess11"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>
    <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">企业信息</span>
            <el-button type="info" size="small" style="background-color: whitesmoke;color: black;" @click="openMachining6(row)" >设置</el-button>
        </td>
      </tr>
    </table>
    <hr style="border-width: 1px;color: black;">
    <!--设置包材-->
    <table style="margin: 10px;">
          <tr>
            <span>公司名称：{{ MachiningForm6.enterpriseName}}</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <span>生产许可证：{{ MachiningForm6.licenseNumber}}</span> 
          </tr>
      <table style="margin-top: 30px;">
      <tr>
        <td>
            <span style="color: black;font-size: 20px">企业照片</span>
        </td>
      </tr>
    </table>
    </table>
    <hr style="border-width: 1px;color: black;">
    <table style="margin: 30px;">
      <tr>
        <td>
          <img v-for="item in imagesList12" :src="item.url" style="width: 100px;height: 100px;margin-right: 15px;"  @click="DeletedImage12(item.url)"/>
        </td>
        <td>
              <el-upload
      class="avatar-uploader"
      action="https://localhost:44391/api/Management/UploadFile"
      :show-file-list="false"
      :on-success="handleAvatarSuccess12"
      :before-upload="beforeAvatarUpload" style="margin-left: 0px;">
  <img v-if="imgForm.url" :src="imgForm.url" class="avatar" style="max-width: 100%;max-height: 100%;margin-left: 0px;" />
  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
      </td>
      </tr>
    </table>

  </el-card>
    </el-main>
  
      
    <!--身体-->
    </el-container>
  </div>
  <div class="common-layout">
   
 </div>
 <div>
  <!--编辑商品页面-->
 <el-dialog v-model="isLock.isOpen" :title="isLock.title" width="500">
    <el-form :model="form">
        <!-- <el-form-item label="商品编号" prop="productCode">
          <el-input v-model="form.productCode" />
        </el-form-item> -->
        <el-form-item label="商品名称">
          <el-select v-model="form.foodId" placeholder="请选择">
            <el-option v-for="item in foodList" :label="item.foodName" :value="item.foodId" />
          </el-select>
        </el-form-item>
        <el-form-item label="生产批次" prop="productionBatch">
          <el-input v-model="form.productionBatch" :disabled="true" />
        </el-form-item>
        <el-form-item label="保质期（天）" prop="shelfLife">
          <el-input v-model="form.shelfLife" />
        </el-form-item>
        <el-form-item  label="生产许可证号" prop="licenseNumber">
          <el-input v-model="form.licenseNumber"/>
        </el-form-item>
        <el-form-item label="生产企业" prop="enterprise">
          <el-input v-model="form.enterprise" />
        </el-form-item>
        <el-form-item label="图片" prop="photoUrl">
          <el-upload
        class="avatar-uploader"
        action="https://localhost:44391/api/Management/UploadFile"
        :show-file-list="false"
        :on-success="handleAvatarSuccess"
        :before-upload="beforeAvatarUpload">
    <img v-if="form.photoUrl" :src="'https://localhost:44391/img/'+form.photoUrl" class="avatar" style="max-width: 100px;max-height: 100px;" />
    <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
  </el-upload>
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="upd()">保存</el-button>
      </div>
    </template>
  </el-dialog> 
  <!--编辑养殖页面-->
  <el-dialog v-model="isLock.isOpen3" title="编辑养殖" width="500">
    <el-form :model="breedForm">
        <el-form-item label="品种" prop="variety">
          <el-input v-model="breedForm.variety" />
        </el-form-item>
        <el-form-item  label="来源" prop="source">
          <el-input v-model="breedForm.source"/>
        </el-form-item>
        <el-form-item label="饲养天数（天）" prop="feedingDays">
          <el-input v-model="breedForm.feedingDays" />
        </el-form-item>
        <el-form-item  label="饲养品种" prop="feedingBrand">
          <el-input v-model="breedForm.feedingBrand"/>
        </el-form-item>
        <el-form-item label="饲养负责人" prop="feedingName">
          <el-input v-model="breedForm.feedingName" />
        </el-form-item>
        <!-- <el-form-item label="出栏日期" prop="saleDate">
          <el-input v-model="breedForm.saleDate" />
        </el-form-item> -->
        <el-form-item label="出栏日期" required>
      <el-col :span="11">
        <el-form-item prop="date1">
          <el-date-picker
            v-model="breedForm.saleDate"
            type="date"
            aria-label="Pick a date"
            placeholder="Pick a date"
            style="width: 100%"
          />
        </el-form-item>
      </el-col>
    </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setBreed()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑企业页面-->
  <el-dialog v-model="isLock.isOpen4" title="编辑企业" width="500">
    <el-form :model="farmForm">
        <el-form-item label="养殖场" prop="variety">
          <el-input v-model="farmForm.farm" />
        </el-form-item>
        <el-form-item  label="负责人" prop="source">
          <el-input v-model="farmForm.custodian"/>
        </el-form-item>
        <el-form-item label="存栏数量（只）" prop="feedingDays">
          <el-input v-model="farmForm.feedNum" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setFarm()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑屠宰页面-->
  <el-dialog v-model="isLock.isOpen5" title="编辑屠宰信息" width="500">
    <el-form :model="slaughteForm">
        <el-form-item label="批次" prop="productionBatch">
          <el-input v-model="slaughteForm.productionBatch" />
        </el-form-item>
        <el-form-item  label="到厂均重" prop="averageWeight">
          <el-input v-model="slaughteForm.averageWeight"/>
        </el-form-item>
        <el-form-item label="到厂日期" required>
      <el-col :span="11">
        <el-form-item prop="date1">
          <el-date-picker
            v-model="slaughteForm.entryTime"
            type="date"
            aria-label="Pick a date"
            placeholder="Pick a date"
            style="width: 100%"
          />
        </el-form-item>
      </el-col>
    </el-form-item>
    <el-form-item label="屠宰日期" required>
      <el-col :span="11">
        <el-form-item prop="date1">
          <el-date-picker
            v-model="slaughteForm.slaughteTime"
            type="date"
            aria-label="Pick a date"
            placeholder="Pick a date"
            style="width: 100%"
          />
        </el-form-item>
      </el-col>
    </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setSlaughte()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑屠宰企业页面-->
  <el-dialog v-model="isLock.isOpen6" title="编辑屠宰企业信息" width="500">
    <el-form :model="slaughteQForm">
        <el-form-item label="公司名称" prop="name">
          <el-input v-model="slaughteQForm.name" />
        </el-form-item>
        <el-form-item label="成立时间" required>
      <el-col :span="11">
        <el-form-item prop="date1">
          <el-date-picker
            v-model="slaughteQForm.foundTime"
            type="date"
            aria-label="Pick a date"
            placeholder="Pick a date"
            style="width: 100%"
          />
        </el-form-item>
      </el-col>
    </el-form-item>
    <el-form-item  label="公司地址" prop="address">
          <el-input v-model="slaughteQForm.address"/>
    </el-form-item>
    <el-form-item  label="公司简介" prop="summary">
          <el-input v-model="slaughteQForm.summary"/>
    </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setSlaughteQ()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑深加工页面-->
  <el-dialog v-model="isLock.isOpen7" title="编辑屠宰企业信息" width="500">
    <el-form :model="MachiningForm">
        <el-form-item label="班组" prop="name">
          <el-input v-model="MachiningForm.team" />
        </el-form-item>
    <el-form-item  label="负责人" prop="address">
          <el-input v-model="MachiningForm.responsiblePerson"/>
    </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setMachining()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑原料页面-->
  <el-dialog v-model="isLock.isOpen8" title="编辑原料信息" width="500">
    <el-form :model="MachiningForm2">
        <el-form-item label="生产批次" prop="roductionBatch">
          <el-input v-model="MachiningForm2.roductionBatch" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setMachining2()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑辅料页面-->
  <el-dialog v-model="isLock.isOpen9" title="编辑辅料信息" width="500">
    <el-form :model="MachiningForm3">
        <el-form-item label="生产批次" prop="productionBatch">
          <el-input v-model="MachiningForm3.productionBatch" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setMachining3()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑添加剂页面-->
  <el-dialog v-model="isLock.isOpen10" title="编辑添加剂信息" width="500">
    <el-form :model="MachiningForm4">
        <el-form-item label="生产批次" prop="productionBatch">
          <el-input v-model="MachiningForm4.productionBatch" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setMachining4()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑包材页面-->
  <el-dialog v-model="isLock.isOpen11" title="编辑包材信息" width="500">
    <el-form :model="MachiningForm5">
        <el-form-item label="生产批次" prop="productionBatch">
          <el-input v-model="MachiningForm5.productionBatch" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setMachining5()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <!--编辑企业信息页面-->
  <el-dialog v-model="isLock.isOpen12" title="编辑加工企业信息" width="500">
    <el-form :model="MachiningForm6">
        <el-form-item label="公司名称" prop="enterpriseName">
          <el-input v-model="MachiningForm6.enterpriseName" />
        </el-form-item>
        <el-form-item label="生产许可证" prop="licenseNumber">
          <el-input v-model="MachiningForm6.licenseNumber" />
        </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button >取消</el-button>
        <el-button type="primary" @click="setMachining6()">保存</el-button>
      </div>
    </template>
  </el-dialog>
  <el-dialog v-model="isLock.isOpen2" title="生成溯源码" width="500">
      <vue-qrcode :value="qrCodeValue" :width="qrCodeSize"></vue-qrcode>
  </el-dialog>
  <el-dialog v-model="dialogVisible">
    <img w-full :src="dialogImageUrl" alt="Preview Image" />
  </el-dialog>
 </div>
 
</template>

<script lang="ts" setup>
import { reactive,ref,onMounted } from 'vue'
import axios from 'axios'
import {useRouter,useRoute} from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import {useCounterStore} from '@/stores/counter'
import { fa } from 'element-plus/es/locales.mjs'
import { Plus } from '@element-plus/icons-vue'
import type { UploadProps,UploadUserFile  } from 'element-plus'
import moment from 'moment'
//#region 定义全局方法
const router=useRouter()
const route=useRoute()
const store=useCounterStore()
const image = new URL('./assets/bg.jpg', import.meta.url).href
const logoSrc = new URL('./assets/logo_1.png', import.meta.url).href
const qrCodeValue = ref("")
const qrCodeSize = ref()
const dialogImageUrl = ref('')
const dialogVisible = ref(false)
const value = ref('养殖信息（5/5）')
//选择卡片
const isCard=ref(1)
const handleRemove: UploadProps['onRemove'] = (uploadFile, uploadFiles) => {
  console.log(uploadFile, uploadFiles)
}
const handlePictureCardPreview: UploadProps['onPreview'] = (uploadFile) => {
  dialogImageUrl.value = uploadFile.url!
  dialogVisible.value = true
}
const options = [
  '养殖信息（5/5）',
  '屠宰信息（5/5）',
  '深加工信息（5/5）',
]
//#endregion

//#region  饲养信息表
const breedForm:any=reactive({
  id:'',
  productCode:'',
  variety:'',
  source:'',
  feedingDays:'',
  feedingBrand:'',
  feedingName:'',
  saleDate:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
const selBreed = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetBreed',
    method:'get'
  })
  .then(res=>{
    breedForm.id=res.data.data.id
    breedForm.productCode=res.data.data.productCode
    breedForm.variety=res.data.data.variety
    breedForm.source=res.data.data.source
    breedForm.feedingDays=res.data.data.feedingDays
    breedForm.feedingBrand=res.data.data.feedingBrand
    breedForm.feedingName=res.data.data.feedingName
    breedForm.saleDate=res.data.data.saleDate
    console.log(res)
  })
}
//#endregion
//#region  养殖信息
const openBreed=(row:any)=>{
  isLock.isOpen3=true
  breedForm.id=row.id
  breedForm.productCode=row.productCode
  breedForm.variety=row.variety
  breedForm.source=row.source
  breedForm.feedingDays=row.feedingDays
  breedForm.feedingBrand=row.feedingBrand
  breedForm.feedingName=row.feedingName
  breedForm.saleDate=row.saleDate
}
const setBreed=()=>{
  axios({
    url:'https://localhost:7223/api/Management/BreedUpd',
    method:'post',
    data:breedForm
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selBreed()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen3=false
  })
}
//#endregion
//#region  企业信息表
const farmForm:any=reactive({
  id:'',
  productCode:'',
  farm:'',
  custodian:'',
  feedNum:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
const selFarm = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetFarm',
    method:'get'
  })
  .then(res=>{
    farmForm.id=res.data.data.id
    farmForm.productCode=res.data.data.productCode
    farmForm.farm=res.data.data.farm
    farmForm.custodian=res.data.data.custodian
    farmForm.feedNum=res.data.data.feedNum
    farmForm.creator=res.data.data.creator
    farmForm.createTime=res.data.data.createTime
    console.log(res)
  })
}
const openFarm=(row:any)=>{
  isLock.isOpen4=true
  farmForm.id=row.id
  farmForm.productCode=row.productCode
  farmForm.farm=row.farm
  farmForm.custodian=row.custodian
  farmForm.feedNum=row.feedNum
  farmForm.creator=row.creator
  farmForm.createTime=row.createTime
}
const setFarm=()=>{
  axios({
    url:'https://localhost:7223/api/Management/FarmUpd',
    method:'post',
    data:farmForm
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selFarm()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen4=false
  })
}
//#endregion
//#region  反填产品
const selProject = () => {
  let obj={
    productId:route.query.productId
  }
  axios({
    url:'https://localhost:44391/api/Management/FanProduct',
    method:'get',
    params:obj
  })
  .then(res=>{
    form.productCode=res.data.data[0].productCode
    form.productionBatch=res.data.data[0].productionBatch
    form.shelfLife=res.data.data[0].shelfLife
    form.licenseNumber=res.data.data[0].licenseNumber
    form.enterprise=res.data.data[0].enterprise
    form.photoUrl=res.data.data[0].photoUrl
    form.foodName=res.data.data[0].foodName
    form.foodId=res.data.data[0].foodId
    console.log(res)
  })
}
const open=(row:any)=>{
    isLock.isOpen=true
    isLock.isAdd=false
    isLock.title="编辑"
    form.productId=route.query.productId
    form.productCode=row.productCode
    form.foodId=row.foodId
    form.productionBatch=row.productionBatch
    form.shelfLife=row.shelfLife
    form.licenseNumber=row.licenseNumber
    form.enterprise=row.enterprise
    form.photoUrl=row.photoUrl 
}
const sym=()=>{
  isLock.isOpen2=true
}
const save=()=>{
  axios({
    url:'https://localhost:7223/api/Management/ProductPhotoAdd',
    method:'post',
    data:form
  })
  .then(res=>{
    if(res.data.code==300){
      ElMessage.success(res.data.msg)
      // router.push('/rolelist')
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
  })
}
const upd=()=>{
  axios({
    url:'https://localhost:7223/api/Management/ProductUpd',
    method:'post',
    data:form
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      // router.push('/rolelist')
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen=false
  })
}
//#endregion
//#region  免疫信息表 
const addImmunity=()=>{
  form.immunity.push({
    productCode:'P0001',
    feedingDays:'',
    immunityType:'',
    immunityMethod:'',
    creator:store.counterAccount.accountNicName,
    createTime:'2024-11-19T12:05:51.381Z',
    isAdd:true,
    isShow:true
  })
}
const saveImmunity=(row:any)=>{
  if(row.isShow==true){
    axios({
    url:'https://localhost:7223/api/Management/ImmunityAdd',
    method:'post',
    data:row
  })
  .then(res=>{
    if(res.data.code==300){
      ElMessage.success(res.data.msg)
      getImmunity()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/ImmunityUpd',
    method:'post',
    data:row
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      getImmunity()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpenImm=false
  })
  }
}
//显示信息
const getImmunity=()=>{
  axios({
    url:'https://localhost:44391/api/Management/GetImmunities',
    method:'get'
  })
  .then(res=>{
    form.immunity=res.data.data
    console.log(res)
  })
  .catch(err=>{
    console.log(err)
  })
}
const immForm=reactive({
  id:'',
  productCode:'',
  feedingDays:'',
  immunityType:'',
  immunityMethod:'',
  creator:'',
  createTime:''
})
const updImmunity=(row:any)=>{
  row.isShow=false
  row.isAdd=true
}
const delImmunity=(row:any)=>{
  ElMessageBox.confirm(
    '确认要删除吗?',
    '警告',
    {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
    url:'https://localhost:7223/api/Management/ImmunityDel',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==400){
      ElMessage.success(res.data.msg)
      getImmunity()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen=false
  })

    })
    .catch(() => {
      ElMessage({
        type:'warning',
        message: '取消删除',
      })
    })
  
  let obj={
    id:row.id
  }
  
}
const cancelImmunity=(row:any)=>{
  getImmunity()
}
//#endregion
//#region  二维码
qrCodeValue.value = 'https://localhost:44391/api/Management/FanProduct?productId=' + route.query.productId
qrCodeSize.value = 400
const fileList = ref<UploadUserFile[]>([
  {
    name: 'food.jpeg',
    url: 'https://localhost:7223/img/233d29d4-9e8d-4b43-ade7-81f5c921f880.png',
  },
])
//#endregion
//#region  上传检测报告
const handleAvatarSuccess=(picName:string)=> {
form.photoUrl=picName;
}
const imgForm=reactive({
  url:'',
})
const handleAvatarSuccess2 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:form.productCode,
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList()
        // GetImagesList();
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList:any=ref([]);
const GetImagesList=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0001'
      }
    })
    .then((res)=>{
      imagesList.value=res.data.data;
    })
}
const DeletedImage=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
const DeletedImages=(url:any)=>{
    axios({
      url:"https://localhost:44391/api/Management/DeleteImages",
      method:"post",
      params:{
        imageName:url
      }
    })
}
//#endregion
//#region  上传动检证
const handleAvatarSuccess3 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0002',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList3()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList3:any=ref([]);
const GetImagesList3=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0002'
      }
    })
    .then((res)=>{
      imagesList3.value=res.data.data;
    })
}
const DeletedImage3=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList3();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  上传企业照片
const handleAvatarSuccess4 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0003',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList4()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList4:any=ref([]);
const GetImagesList4=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0003'
      }
    })
    .then((res)=>{
      imagesList4.value=res.data.data;
    })
}
const DeletedImage4=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList4();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
const beforeAvatarUpload: UploadProps['beforeUpload'] = (rawFile) => {
   if (rawFile.size / 1024 / 1024 > 2) {
    ElMessage.error('大小不能超过2MB!')
    return false
  }
  return true
}
//#endregion
//#region  屠宰信息
const openSlaughte=(row:any)=>{
  isLock.isOpen5=true
  slaughteForm.id=row.id
  slaughteForm.productCode=row.productCode
  slaughteForm.productionBatch=row.productionBatch
  slaughteForm.averageWeight=row.averageWeight
  slaughteForm.entryTime=row.entryTime
  slaughteForm.slaughteTime=row.slaughteTime
  slaughteForm.creator=row.creator
  slaughteForm.createTime=row.createTime
}
const slaughteForm:any=reactive({
  id:'',
  productCode:'P0001',
  productionBatch:'',
  averageWeight:'',
  entryTime:'',
  slaughteTime:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let slaughteList=ref([])
const selSlaughte = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetSlaughte',
    method:'get'
  })
  .then(res=>{
    slaughteList.value=res.data.data
    slaughteForm.id=res.data.data.id
    slaughteForm.productCode=res.data.data.productCode
    slaughteForm.productionBatch=res.data.data.productionBatch
    slaughteForm.averageWeight=res.data.data.averageWeight
    slaughteForm.entryTime=res.data.data.entryTime
    slaughteForm.slaughteTime=res.data.data.slaughteTime
    slaughteForm.creator=res.data.data.creator
    slaughteForm.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setSlaughte=()=>{
  if(slaughteList.value==null){
    let obj={
      productCode:slaughteForm.productCode,
      productionBatch:slaughteForm.productionBatch,
      averageWeight:slaughteForm.averageWeight,
      entryTime:slaughteForm.entryTime,
      slaughteTime:slaughteForm.slaughteTime,
      creator:slaughteForm.creator,
      createTime:slaughteForm.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/SlaughteUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selSlaughte()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen5=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/SlaughteUpd',
    method:'post',
    data:slaughteForm
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selSlaughte()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen5=false
  })
  }
  
}
//#endregion
//#region  上传相关资料
const handleAvatarSuccess5 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0004',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList5()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList5:any=ref([]);
const GetImagesList5=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0004'
      }
    })
    .then((res)=>{
      imagesList5.value=res.data.data;
    })
}
const DeletedImage5=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList5();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  屠宰企业信息
const openSlaughteQ=(row:any)=>{
  isLock.isOpen6=true
}
const slaughteQForm:any=reactive({
  id:'',
  productCode:'P0001',
  name:'',
  foundTime:'',
  address:'',
  summary:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let slaughteQList=ref([])
const selSlaughteQ = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetSlaughteQ',
    method:'get'
  })
  .then(res=>{
    slaughteQList.value=res.data.data
    slaughteQForm.id=res.data.data.id
    slaughteQForm.productCode=res.data.data.productCode
    slaughteQForm.name=res.data.data.name
    slaughteQForm.foundTime=res.data.data.foundTime
    slaughteQForm.address=res.data.data.address
    slaughteQForm.summary=res.data.data.summary
    slaughteQForm.creator=res.data.data.creator
    slaughteQForm.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setSlaughteQ=()=>{
  if(slaughteQList.value==null){
    let obj={
      productCode:slaughteQForm.productCode,
      name:slaughteQForm.name,
      foundTime:slaughteQForm.foundTime,
      address:slaughteQForm.address,
      summary:slaughteQForm.summary,
      creator:slaughteQForm.creator,
      createTime:slaughteQForm.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/SlaughteQUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selSlaughteQ()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen6=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/SlaughteQUpd',
    method:'post',
    data:slaughteQForm
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selSlaughteQ()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen6=false
  })
  }
  
}
//#endregion
//#region  企业照片
const handleAvatarSuccess6 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0005',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList6()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList6:any=ref([]);
const GetImagesList6=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0005'
      }
    })
    .then((res)=>{
      imagesList6.value=res.data.data;
    })
}
const DeletedImage6=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList6();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  深加工信息
const openMachining=(row:any)=>{
  isLock.isOpen7=true
}
const MachiningForm:any=reactive({
  id:'',
  productCode:'P0001',
  team:'',
  responsiblePerson:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let MachiningList=ref([])
const selMachining = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetMachining',
    method:'get'
  })
  .then(res=>{
    MachiningList.value=res.data.data
    MachiningForm.id=res.data.data.id
    MachiningForm.productCode=res.data.data.productCode
    MachiningForm.team=res.data.data.team
    MachiningForm.responsiblePerson=res.data.data.responsiblePerson
    MachiningForm.creator=res.data.data.creator
    MachiningForm.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setMachining=()=>{
  if(MachiningList.value==null){
    let obj={
      productCode:MachiningForm.productCode,
      team:MachiningForm.team,
      responsiblePerson:MachiningForm.responsiblePerson,
      creator:MachiningForm.creator,
      createTime:MachiningForm.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/MachiningUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selMachining()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen7=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/MachiningUpd',
    method:'post',
    data:MachiningForm
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selMachining()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen7=false
  })
  }
  
}
//#endregion
//#region  食品安全照片
const handleAvatarSuccess7 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0006',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList7()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList7:any=ref([]);
const GetImagesList7=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0006'
      }
    })
    .then((res)=>{
      imagesList7.value=res.data.data;
    })
}
const DeletedImage7=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList7();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  原料信息
const openMachining2=(row:any)=>{
  isLock.isOpen8=true
}
const MachiningForm2:any=reactive({
  id:'',
  roductCode:'P0001',
  roductionBatch:'',
  reator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let MachiningList2=ref([])
const selMachining2 = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetMaterial',
    method:'get'
  })
  .then(res=>{
    MachiningList2.value=res.data.data
    MachiningForm2.id=res.data.data.id
    MachiningForm2.roductCode=res.data.data.roductCode
    MachiningForm2.roductionBatch=res.data.data.roductionBatch
    MachiningForm2.reator=res.data.data.reator
    MachiningForm2.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setMachining2=()=>{
  if(MachiningList2.value==null){
    let obj={
      roductCode:MachiningForm2.roductCode,
      roductionBatch:MachiningForm2.roductionBatch,
      reator:MachiningForm2.reator,
      createTime:MachiningForm2.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/MaterialUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selMachining2()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen8=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/MaterialUpd',
    method:'post',
    data:MachiningForm2
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selMachining2()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen8=false
  })
  }
  
}
//#endregion
//#region  食品安全照片
const handleAvatarSuccess8 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0007',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList8()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList8:any=ref([]);
const GetImagesList8=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0007'
      }
    })
    .then((res)=>{
      imagesList8.value=res.data.data;
    })
}
const DeletedImage8=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList8();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  辅料信息
const openMachining3=(row:any)=>{
  isLock.isOpen9=true
}
const MachiningForm3:any=reactive({
  id:'',
  productCode:'P0001',
  productionBatch:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let MachiningList3=ref([])
const selMachining3 = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetAccessories',
    method:'get'
  })
  .then(res=>{
    MachiningList3.value=res.data.data
    MachiningForm3.id=res.data.data.id
    MachiningForm3.productCode=res.data.data.productCode
    MachiningForm3.productionBatch=res.data.data.productionBatch
    MachiningForm3.creator=res.data.data.creator
    MachiningForm3.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setMachining3=()=>{
  if(MachiningList3.value==null){
    let obj={
      productCode:MachiningForm3.productCode,
      productionBatch:MachiningForm3.productionBatch,
      creator:MachiningForm3.creator,
      createTime:MachiningForm3.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/AccessoriesUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selMachining3()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen9=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/AccessoriesUpd',
    method:'post',
    data:MachiningForm3
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selMachining3()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen9=false
  })
  }
  
}
//#endregion
//#region  辅料照片
const handleAvatarSuccess9 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0008',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList9()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList9:any=ref([]);
const GetImagesList9=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0008'
      }
    })
    .then((res)=>{
      imagesList9.value=res.data.data;
    })
}
const DeletedImage9=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList9();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  添加剂信息
const openMachining4=(row:any)=>{
  isLock.isOpen10=true
}
const MachiningForm4:any=reactive({
  id:'',
  productCode:'P0001',
  productionBatch:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let MachiningList4=ref([])
const selMachining4 = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetAdditive',
    method:'get'
  })
  .then(res=>{
    MachiningList4.value=res.data.data
    MachiningForm4.id=res.data.data.id
    MachiningForm4.productCode=res.data.data.productCode
    MachiningForm4.productionBatch=res.data.data.productionBatch
    MachiningForm4.creator=res.data.data.creator
    MachiningForm4.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setMachining4=()=>{
  if(MachiningList4.value==null){
    let obj={
      productCode:MachiningForm4.productCode,
      productionBatch:MachiningForm4.productionBatch,
      creator:MachiningForm4.creator,
      createTime:MachiningForm4.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/AdditiveUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selMachining4()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen10=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/AdditiveUpd',
    method:'post',
    data:MachiningForm4
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selMachining4()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen10=false
  })
  }
  
}
//#endregion
//#region  添加剂照片
const handleAvatarSuccess10 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0009',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList10()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList10:any=ref([]);
const GetImagesList10=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0009'
      }
    })
    .then((res)=>{
      imagesList10.value=res.data.data;
    })
}
const DeletedImage10=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList10();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  包材信息
const openMachining5=(row:any)=>{
  isLock.isOpen11=true
}
const MachiningForm5:any=reactive({
  id:'',
  productCode:'P0001',
  productionBatch:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let MachiningList5=ref([])
const selMachining5 = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetPack',
    method:'get'
  })
  .then(res=>{
    MachiningList5.value=res.data.data
    MachiningForm5.id=res.data.data.id
    MachiningForm5.productCode=res.data.data.productCode
    MachiningForm5.productionBatch=res.data.data.productionBatch
    MachiningForm5.creator=res.data.data.creator
    MachiningForm5.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setMachining5=()=>{
  if(MachiningList5.value==null){
    let obj={
      productCode:MachiningForm5.productCode,
      productionBatch:MachiningForm5.productionBatch,
      creator:MachiningForm5.creator,
      createTime:MachiningForm5.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/PackeUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selMachining5()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen11=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/PackeUpd',
    method:'post',
    data:MachiningForm5
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selMachining5()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen11=false
  })
  }
  
}
//#endregion
//#region  包材照片
const handleAvatarSuccess11 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0010',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList11()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList11:any=ref([]);
const GetImagesList11=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0010'
      }
    })
    .then((res)=>{
      imagesList11.value=res.data.data;
    })
}
const DeletedImage11=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList11();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion
//#region  加工企业信息
const openMachining6=(row:any)=>{
  isLock.isOpen12=true
}
const MachiningForm6:any=reactive({
  id:'',
  productCode:'P0001',
  enterpriseName:'',
  licenseNumber:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now
})
let MachiningList6=ref([])
const selMachining6 = () => {
  axios({
    url:'https://localhost:44391/api/Management/GetMachiningJ',
    method:'get'
  })
  .then(res=>{
    MachiningList6.value=res.data.data
    MachiningForm6.id=res.data.data.id
    MachiningForm6.productCode=res.data.data.productCode
    MachiningForm6.enterpriseName=res.data.data.enterpriseName
    MachiningForm6.licenseNumber=res.data.data.licenseNumber
    MachiningForm6.creator=res.data.data.creator
    MachiningForm6.createTime=res.data.data.createTime
    console.log(res)
  })
}
const setMachining6=()=>{
  if(MachiningList6.value==null){
    let obj={
      productCode:MachiningForm6.productCode,
      enterpriseName:MachiningForm6.enterpriseName,
      licenseNumber:MachiningForm6.licenseNumber,
      creator:MachiningForm6.creator,
      createTime:MachiningForm6.createTime,
    }
    axios({
    url:'https://localhost:7223/api/Management/MachiningJUpd',
    method:'post',
    data:obj
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success("添加成功")
      selMachining6()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen12=false
  })
  }else{
    axios({
    url:'https://localhost:7223/api/Management/MachiningJUpd',
    method:'post',
    data:MachiningForm6
  })
  .then(res=>{
    if(res.data.code==500){
      ElMessage.success(res.data.msg)
      selMachining6()
    }else{
      ElMessage.error(res.data.msg)
    }
    console.log(res)
    isLock.isOpen12=false
  })
  }
  
}
//#endregion
//#region  企业照片
const handleAvatarSuccess12 =(img:string)=> {
  var url = "https://localhost:44391"+img;
  axios({
      url:"https://localhost:7223/api/Management/ImageAdd",
      method:"post",
      data:{
        traceType:0,
        productCode:'P0011',
        imgType:0,
        url:url,
      }
    })
    .then((res)=>{
      if(res.data.code==300){
        ElMessage.success(res.data.msg)
        GetImagesList12()
      }
      else{
        ElMessage.success(res.data.msg)
        DeletedImages(url)
      }
    })
}
const imagesList12:any=ref([]);
const GetImagesList12=()=>{
    axios({
      url:"https://localhost:44391/api/Management/GetImage",
      method:"get",
      params:{
        productCode:'P0011'
      }
    })
    .then((res)=>{
      imagesList12.value=res.data.data;
    })
}
const DeletedImage12=(url:any)=>{
  ElMessageBox.confirm(
    '确认是否删除?',
    '删除',
    {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
    }
  )
    .then(() => {
      axios({
        url:"https://localhost:7223/api/Management/DeleteImage",
        method:"post",
        data:{
          url:url,
        }
      })
      .then((res)=>{
        if(res.data.code==400){
          ElMessage.success(res.data.msg)
          GetImagesList12();
          DeletedImages(url)
        }
        else{
          ElMessage.info(res.data.msg)
        }
      })
    })
    .catch(() => {
      ElMessage({
        type: 'info',
        message: '取消成功',
      })
    })
}
//#endregion

//食物下拉
const foodList:any=ref([])
const GetFood = ()=>{
  axios({
    url:'https://localhost:44391/api/Management/GetFood',
    method:'get'
  })
  .then(res=>{
    foodList.value=res.data.data
    console.log(res)
  })
  .catch(err=>{
    console.log(err)
  })
}
const isLock=reactive({
  isOpen:false,
  isOpen2:false,
  isOpen3:false,
  isOpen4:false,//打开企业对话框
  isOpen5:false,//打开屠宰对话框
  isOpen6:false,//打开屠宰企业对话框
  isOpen7:false,//打开深加工对话框
  isOpen8:false,//打开原料对话框
  isOpen9:false,//打开辅料对话框
  isOpen10:false,//打开添加剂对话框
  isOpen11:false,//打开包材剂对话框
  isOpen12:false,//打开加工企业对话框
  isOpenImm:false,
  title:'',
  isAdd:false
})
const form:any=reactive({
  productId:'',
  productCode:'',
  foodId:'',
  foodName:'',
  productionBatch:'',
  shelfLife:'',
  licenseNumber:'',
  enterprise:'',
  creator:store.counterAccount.accountNicName,
  createTime:Date.now,
  updator:store.counterAccount.accountNicName,
  updateTime:Date.now,
  deletor:store.counterAccount.accountNicName,
  deleteTime:Date.now,
  photoUrl:'',
  //免疫信息表
  immunity:<any>[]
})
onMounted(()=>{
  selProject()
  GetFood()
  selBreed()
  getImmunity()
  GetImagesList()
  GetImagesList3()
  GetImagesList4()
  selFarm()//获取企业信息
  selSlaughte()//获取屠宰信息
  GetImagesList5()//相关资料
  selSlaughteQ()//获取屠宰企业
  GetImagesList6()//企业照片
  selMachining()//获取深加工
  GetImagesList7()//食品安全
  selMachining2()//获取原料
  GetImagesList8()
  selMachining3()//获取辅料
  GetImagesList9()//辅料相关材料
  selMachining4()//获取添加剂
  GetImagesList10()//添加剂相关材料
  selMachining5()//获取包材
  GetImagesList11()//添加剂相关材料
  selMachining6()//获取深加工企业
  GetImagesList12()//企业相关材料
})

</script>


<style scoped>
.common-layout{
  background-color: whitesmoke;
}
.avatar-uploader .avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
<style>
.avatar-uploader .el-upload {
  border: 1px dashed var(--el-border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
}

.avatar-uploader .el-upload:hover {
  border-color: var(--el-color-primary);
}

.el-icon.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 28px;
  height: 28px;
  text-align: center;
}
</style>